package com.xingzuo.library_translation.ui.fragment;

import android.util.Log;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.ogaclejapan.smarttablayout.SmartTabLayout;
import com.xingzuo.base.app.AppActivityKey;
import com.xingzuo.base.ui.mvp.base.ui.BaseFragment;
import com.xingzuo.common.adapter.MyTitleViewPagerAdapter;
import com.xingzuo.library_translation.R;
import com.xingzuo.library_translation.R2;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

@Route(path = AppActivityKey.TRANSLATIONFRAGMENT)
public class TranslationFragment extends BaseFragment {

    @BindView(R2.id.sl_report)
    SmartTabLayout slReport;
    @BindView(R2.id.vp_content)
    ViewPager vpContent;
    private List<Fragment> fragments = new ArrayList<>();
    private List<String> titleList = new ArrayList<>();
    private MyTitleViewPagerAdapter myTitleViewPagerAdapter;

    @Override
    public int getViewId() {
        return R.layout.fragment_translation;
    }

    @Override
    public void initView() {
        myTitleViewPagerAdapter = new MyTitleViewPagerAdapter(getChildFragmentManager(), fragments, titleList);
        vpContent.setAdapter(myTitleViewPagerAdapter);
        vpContent.setOffscreenPageLimit(4);
        slReport.setViewPager(vpContent);
        vpContent.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                Log.e("insert", position + "==onPageScrolled==");
            }

            @Override
            public void onPageSelected(int position) {
                Log.e("insert", position + "==onPageSelected==");
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }

    @Override
    public void initLinsenterner() {

    }

    @Override
    public void getData() {
        fragments.add(new TranslationListFrgament());
        fragments.add(new TranslationListFrgament());
        fragments.add(new TranslationListFrgament());
        titleList.add("关注");
        titleList.add("推荐");
        titleList.add("最新");
    }

    @OnClick(R2.id.fl_add)
    public void onViewClicked() {
        startIntent(AppActivityKey.RELEASEACTIVITY);
    }
}